import { Injectable } from "@angular/core";
import { Observable } from "rxjs/Observable";
import { HttpClient, HttpParams, HttpResponse } from '@angular/common/http';
import { BaseHttpService } from "../../../../shared/services/baseHttp.service";
import { InvolvementAssessmentModel } from "../productInvolvement/models/involvementAssessment.model";


/**
 * Company product involvement service
 * 
 * Author: Sorin Spiru
 * Date: 09.03.2018
 */
@Injectable()
export class CompanySustainableProductsService extends BaseHttpService {
    constructor(public http: HttpClient) {
        super();
    }

    /**
     * Get all possible assessments
     */
    public getAssessments(): Observable<any/* InvolvementAssessmentModel[]*/> {
        return this.http.get<any/*InvolvementAssessmentModel[]*/>(this.serverUrl + 'sustainableproductsserv/api/v1/companyassessments/');
    }

    /**
     * Get company assessments involvement
     * @param companyId Company unique identifier
     */
    public getCompanyInvolvementAssessment(companyId: string): Observable<HttpResponse<any>> {
        return this.http.get<HttpResponse<any>>(this.serverUrl + 'sustainableproductsserv/api/v1/companyassessments/' + companyId, {responseType: 'json', observe: 'response'});
    }

    public getHasActiveInvolvedAssessments(companyId: string): Observable<HttpResponse<any>> {
        return this.http.get<HttpResponse<any>>(this.serverUrl + 'sustainableproductsserv/api/v1/companyassessments/' + companyId + '/' + true , {responseType: 'json', observe: 'response'});
    }
    
}